package com.zkyc.framework.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zkyc.framework.common.pojo.MediaTag;
import com.zkyc.framework.common.pojo.MediaTagGroup;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @author bing.bai
 * @create 2022/6/14
 */
@Mapper
public interface MediaTagGroupMapper extends BaseMapper<MediaTagGroup> {
    @Select("SELECT * from system_media_tag where tag_group_id=#{mediaGroupId} and is_deleted=0")
    public List<MediaTag> findMediaTagByGroupId(int mediaGroupId);

    @Select("SELECT * from system_media_tag_group where is_deleted=0 and website_id = #{websiteId}")
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.INTEGER, id=true),
            @Result(column="media_group_name", property="mediaGroupName", jdbcType=JdbcType.VARCHAR),
            @Result(column="id",
                    property="mediaTagList",
                    javaType=List.class,
                    many = @Many(select = "findMediaTagByGroupId"))
    })
    public List<MediaTagGroup> getMediaTagGroupList(String websiteId);
}
